package com.logistics.erp.entity.model;

import com.logistics.erp.entity.domain.ErpDeliveryOrderDetail;
import com.logistics.erp.entity.domain.MaterialFlow;
import com.logistics.utils.tool.DateUtils;
import com.logistics.utils.tool.StringUtils;
import lombok.Data;

@Data
public class MaterialFlowRow {

    private String nextDeptCodeWc;

    private String sourceMethod;

    private String shopOrder;

    private String companyCode;

    private String deptCode;

    private String itemCode;

    private String itemName;

    private String unitCode;

    private String unitName;

    private String receiveQty;

    private String wcCode;

    private String wcName;

    private String customerName;

    private String opNo;

    private String workNo;

    private String deptCodeWc;

    private String deptNameWc;

    private String planQty;

    private String startDate;

    private String ztStatus;

    private String reqQty;

    private String isnbjj;

    private String orderStatus;

    private String intoDeptW;

    private String intoTime;

    private String intoDeptWName;

    private String orderQty;

    private String message;

    private String paintLocation;

    private String mode;

    public MaterialFlowRow(){}

    public MaterialFlowRow(MaterialFlow flow){
        this.sourceMethod = flow.getSourceMethod();
        this.nextDeptCodeWc = flow.getNextDeptCodeWc();
        this.reqQty =flow.getReqQty();
        this.isnbjj = flow.getIsnbjj();
        this.orderStatus = flow.getOrderStatus();
        this.intoDeptW = flow.getIntoDeptW();
        this.intoTime = flow.getIntoTime();
        this.intoDeptWName = flow.getIntoDeptWName();
        this.shopOrder = flow.getShopOrder();
        this.companyCode = flow.getCompanyCode();
        this.deptCode = flow.getDeptCode();
        this.itemCode = flow.getItemCode();
        this.itemName = flow.getItemName();
        this.unitCode = flow.getUnitCode();
        this.unitName = flow.getUnitName();
        this.receiveQty = flow.getReceiveQty();
        this.wcCode = flow.getWcCode();
        this.wcName = flow.getWcName();
        this.customerName = flow.getCustomerName();
        this.opNo = flow.getOpNo();
        this.workNo = flow.getWorkNo();
        this.deptCodeWc = flow.getDeptCodeWc();
        this.deptNameWc = flow.getDeptNameWc();
        this.planQty = flow.getPlanQty();
        this.startDate = DateUtils.dateToStringFormat(DateUtils.stringToDateFormat(flow.getStartDate(), DateUtils.YYYY_MM_DD_SLASH), DateUtils.YYYY_MM_DD_SLASH);
        this.ztStatus = flow.getZtStatus();
        this.orderQty = flow.getOrderQty();
        this.paintLocation = flow.getPaintLocation();
    }

    public static MaterialFlowRow build(MaterialFlow flow){
        return new MaterialFlowRow(flow);
    }

    public MaterialFlowRow(ErpDeliveryOrderDetail flow, String message, String mode){
        this.sourceMethod = flow.getSourceMethod();
        this.wcName = flow.getNextDeptNameWc();
        this.workNo = flow.getWorkNo();
        this.shopOrder = flow.getShopOrder();
        this.orderQty = StringUtils.isNotNull(flow.getQty()) ? flow.getQty().toString() : null;
        //this.planQty = StringUtils.isNotNull(flow.getQty()) ? flow.getQty().toString() : null;
        this.startDate = DateUtils.dateToStringFormat(DateUtils.stringToDateFormat(flow.getNextStartDate(), DateUtils.YYYY_MM_DD_SLASH), DateUtils.YYYY_MM_DD_SLASH);
        this.message = message;
        this.mode = mode;
    }

    public static MaterialFlowRow build(ErpDeliveryOrderDetail flow, String message, String mode){
        return new MaterialFlowRow(flow, message, mode);
    }
}
